package com.baizhi.jishi.controller;

import com.baizhi.jishi.entity.Department;
import com.baizhi.jishi.entity.MyTree;
import com.baizhi.jishi.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @RequestMapping("/showPage")
    @ResponseBody
    public Map showPage(int page,int limit,String departmentname){
        //System.out.println(departmentname);
        return departmentService.showPage(page, limit, departmentname);
    }
    @RequestMapping("/adddepartment")
    @ResponseBody
    public Map adddepartment(Department department){
        System.out.println(department);
        return departmentService.adddepartment(department);
    }
    @RequestMapping("/deleteDepartment")
    @ResponseBody
    public Map deleteDepartment(int id){
        return departmentService.deleteDepartment(id);
    }
    @RequestMapping("/selectOne")
    @ResponseBody
    public Map selectOne(int id){
        return departmentService.selectOne(id);
    }
    @RequestMapping("/updateDepartment")
    @ResponseBody
    public Map updateDepartment(Department department){
        return departmentService.updateDepartment(department);
    }
    @RequestMapping("/deleteSome")
    @ResponseBody
    public Map deleteSome(int[] ids){
        return departmentService.deleteSome(ids);
    }
    @RequestMapping("/showAll")
    @ResponseBody
    public List<MyTree> showAll(){
        return departmentService.showAll();
    }
}
